package com.wcl.demo.ui.activity;

import com.wcl.demo.presenter.BasePresenter;

/**
 * Created by dllo on 15/11/17.
 */
public abstract class MVPBaseActivity<V, T extends BasePresenter<V>> extends BaseActivity {
    protected T mPresenter;

    @Override
    protected void initPresenter() {
        /** 声明Presenter对象 */
        super.initPresenter();
        mPresenter = createPresenter();
        mPresenter.attachView((V) this);
    }

    /**
     * 创建Presenter
     *
     * @return
     */
    protected abstract T createPresenter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        // 清理应用对象
        mPresenter.detachView();
    }
}
